package o;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import com.huawei.hwid.core.constants.HwAccountConstants;

class eof {
    private static String ˏ = "HwIdHasLogin";

    eof() {
    }

    public static int ॱ(Context context) {
        if (((eov) cdb.ॱ(eov.class)).ॱ(context)) {
            return 0;
        }
        try {
            return ॱ(context.getContentResolver(), Uri.parse(HwAccountConstants.CONTENT_HASLOGIN_URL));
        } catch (Exception e) {
            Logger.ˋ(ˏ, "Exception when checking has HwID login.");
            return -1;
        }
    }

    private static int ॱ(ContentResolver contentResolver, Uri uri) {
        Throwable th;
        Cursor query;
        try {
            query = contentResolver.query(uri, null, null, null, null);
            if (query != null) {
                try {
                    if (query.moveToFirst() && query.getInt(query.getColumnIndex("hasLogin")) == 1) {
                        if (query != null) {
                            query.close();
                        }
                        return 1;
                    } else if (query == null) {
                        return 0;
                    } else {
                        query.close();
                        return 0;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    if (query != null) {
                        query.close();
                    }
                    throw th;
                }
            } else if (query == null) {
                return -1;
            } else {
                query.close();
                return -1;
            }
        } catch (Throwable th3) {
            th = th3;
            query = null;
            if (query != null) {
                query.close();
            }
            throw th;
        }
    }
}
